from django.contrib.auth.models import User
from rest_framework import serializers

from .models import *

class BookSerializer(serializers.ModelSerializer):
    owner = serializers.SlugRelatedField(many=True, queryset=User.objects.all(), slug_field='username')

    class Meta:
        model = Book
        fields = ( 'id', 'name', 'author', 'publisher', 'owner')
